package top.yoahh.system.controller;


import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.yoahh.annotation.AutoLog;
import top.yoahh.system.query.SysLogQueryInfo;

import top.yoahh.common.Result;
import top.yoahh.system.entity.SysLog;
import java.util.List;

import org.springframework.web.bind.annotation.RestController;
import top.yoahh.system.service.SysLogService;
/**
 * <p>
 * 系统设置-日志表 前端控制器
 * </p>
 *
 * @author hjx
 * @since 2022-05-15
 */
@RestController
@Api(tags = "系统设置-日志表")
@RequestMapping("/sysLog")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    @AutoLog(value = "系统设置-日志表-新增")
    @ApiOperation(value = "新增")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public Result add(@RequestBody SysLog sysLog){
        sysLogService.save(sysLog);
        return Result.ok();
    }

    @AutoLog(value = "系统设置-日志表-分页查询")
    @ApiOperation(value = "分页查询")
    @RequestMapping(value = "/queryPage",method = RequestMethod.POST)
    public PageInfo<SysLog> queryPage(@RequestBody SysLogQueryInfo queryInfo){
        return sysLogService.queryPage(queryInfo);
    }

    @AutoLog(value = "系统设置-日志表-批量删除")
    @ApiOperation(value = "批量删除")
    @RequestMapping(value = "/deleteBatch",method = RequestMethod.DELETE)
    public Result deleteBatch(@RequestBody List<String> ids){
        return sysLogService.deleteBatch(ids);
    }

    @AutoLog(value = "系统设置-日志表-按照ID删除")
    @ApiOperation(value = "按照ID删除")
    @RequestMapping(value = "/delete/{id}",method = RequestMethod.DELETE)
    public Result delete(@PathVariable("id") String id){
        return sysLogService.delete(id);
    }

    @AutoLog(value = "系统设置-日志表-修改")
    @ApiOperation(value = "修改")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public Result update(@RequestBody SysLog sysLog){
        sysLogService.updateById( sysLog);
        return Result.ok();
    }
}
